<template>
<div class="base-box">
    <div class="f1 goods-content">
        <div class="resource-book-3">
            <section class="cz-c f1 resource-book-3-1">
                <img class="book-detail-image" :src="getUrl">
            </section>
                <section class="resource-book-3-2">
                    <h4>{{getBook.title}}</h4>
                    <section class="resource-book-5">
                        <p class="resource-book-5-p-1">主编:{{getBook.editor}}</p>
                        <p class="resource-book-5-p-1">出版社:{{getBook.press}}</p>
                        <p class="resource-book-5-p-1">适用层次:{{getBook.level}}</p>
                        <p class="resource-book-5-p-1">出版/修订日期:{{getBook.date}}</p>
                        <p class="resource-book-5-p-2"><i class="font3">￥{{getBook.price}}</i></p>
                    </section>
                    <section class="resource-book-4">
                        <span class="f1" @click="add(getBook.id)">加入购物车</span>
                    </section>
                </section>
        </div>
        <section class="resource-book-6 shh-book-tab">
            <span class="f1 active">内容简介</span>
        </section>
        <div class="resource-book-7">
            <div class="resource-book-catalogue">
                <span v-html="getBook.info"></span>
            </div>
        </div>
    </div>
</div>
</template>
<script setup>
import books from '../assets/json/books.json'
import {computed} from 'vue'
import {useStore} from 'vuex'
const store = useStore()
const props = defineProps(['id'])
const getBook = computed(()=>{return books[props.id-1]})
const getUrl = computed(()=>{
    return new URL(getBook.value.image,import.meta.url).href
})
const add = (id)=>{
    if(store.getters.isLogin){
        store.commit('add',id)
    }else{
        alert("请登录")
    }
}
</script>
<style scoped>
.base-box {
    width: 1200px;
    height: auto;
    overflow: hidden;
    margin: 0 auto;
    background-color: #fff;
}

.f1 {
    float: left;
}

.goods-content {
    border-radius: 4px;
    background-color: #ffffff;
    /* width: 780px; */
    min-height: 760px;
    overflow: hidden;
    margin-top: 20px;
    margin-left: 20px;
    margin-right: 20px;
}

.resource-book-3 {
    width: 1160px;
    height: auto;
    overflow: hidden;
    margin: 0px;
}

.resource-book-3-1 {
    width: 188px;
    height: 258px;
    border: 1px solid #E6E6E6;
    overflow: hidden;
}

.cz-c {
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-detail-image {
    max-height: 256px;
    width: auto;
    max-width: 100%;
    overflow: hidden;
}

img {
    border: none;
    vertical-align: middle;
    overflow: hidden;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.fr {
    float: right;
}

.resource-book-3-2 {
    padding-left: 20px;
    width: 570px;
    height: auto;
    overflow: hidden;
    text-align: left;
    color: #333333;
    margin: 0px;
}

.resource-book-3-2 h4 {
    color: #333333;
    font-size: 20px;
    margin: 0px;
}

.resource-book-5 {
    margin: 0px;
    width: 550px;
    height: 150px;
    background-color: #F5F7F6;
    margin: 14px auto;
    line-height: 28px;
    font-size: 14px;
    padding: 10px;
}

.resource-book-5-p-1 {
    margin: 0px;
}

.resource-book-5-p-2 {
    margin: 0px;
    margin-top: 5px;
}

.font3 {
    color: #FF0000;
    font-size: 22px;
}

i {
    font-style: normal;
}

.resource-book-4 {
    width: 100%;
    height: 36px;
    overflow: hidden;
}

.resource-book-4 span {
    border-radius: 2px;
    width: 120px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    color: #ffffff;
    font-size: 16px;
    display: block;
    background-color: #FF711D;
    border: 1px solid #FF711D;
}

.active {
    background-color: #ffffff;
    color: #FF711D;
    margin-left: 30px;
}

.resource-book-6 {
    margin: 0px;
    width: 1160px;
    height: 50px;
    background-color: #F5F7F6;
    line-height: 50px;
    color: #333333;
    font-size: 16px;
    margin-top: 25px;
    /* margin: 25px auto; */
    overflow: hidden;
}

.shh-book-tab {
    overflow: initial;
}

.resource-book-6 span {
    padding: 0px 30px;
    cursor: pointer;
    position: relative;
    margin: 0px;
}

.resource-book-6 span .active {
    color: #16CA82;
    background-color: #ffffff;
}

.resource-book-6 span.active::after {
    content: ' ';
    width: 1160px;
    height: 2px;
    background-color: #16CA82;
    position: absolute;
    left: 0;
}

.resource-book-7 {
    width: 1160px;
    height: auto;
    line-height: 26px;
    padding-bottom: 50px;
    overflow: hidden;
    text-align: justify;
}

.resource-book-catalogue {
    width: 100%;
    max-height: 760px;
    line-height: 26px;
    margin-bottom: 50px;
    overflow: auto;
    text-align: justify;
}
</style>